home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Entwickler / Mac-OS / oxygen / samples / docbook / xsl / html / lists.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-09  |  30.1 KB  |  969 lines  |  [□□□□/□□□□]

  1.     lists.xslv-π¢tÚπ¢tÚÅÅ:o<?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 version='1.0'>
  4.  
  5. <!-- ********************************************************************
  6.      $Id: lists.xsl,v 1.1 2002/05/29 09:55:49 dan Exp $
  7.      ********************************************************************
  8.  
  9.      This file is part of the XSL DocBook Stylesheet distribution.
  10.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  11.      and other information.
  12.  
  13.      ******************************************************************** -->
  14.  
  15. <!-- ==================================================================== -->
  16.  
  17. <xsl:template match="itemizedlist">
  18.   <xsl:variable name="itemsymbol">
  19.     <xsl:call-template name="list.itemsymbol"/>
  20.   </xsl:variable>
  21.  
  22.   <div class="{name(.)}">
  23.     <xsl:call-template name="anchor"/>
  24.     <xsl:if test="title">
  25.       <xsl:apply-templates select="title"/>
  26.     </xsl:if>
  27.     <ul type="{$itemsymbol}">
  28.       <xsl:if test="@spacing='compact'">
  29.         <xsl:attribute name="compact">
  30.           <xsl:value-of select="@spacing"/>
  31.         </xsl:attribute>
  32.       </xsl:if>
  33.       <xsl:apply-templates select="listitem"/>
  34.     </ul>
  35.   </div>
  36. </xsl:template>
  37.  
  38. <xsl:template match="itemizedlist/title">
  39.   <p class="title"><b><xsl:apply-templates/></b></p>
  40. </xsl:template>
  41.  
  42. <xsl:template match="itemizedlist/listitem">
  43.   <xsl:variable name="mark" select="../@mark"/>
  44.   <xsl:variable name="override" select="@override"/>
  45.  
  46.   <xsl:variable name="usemark">
  47.     <xsl:choose>
  48.       <xsl:when test="$override != ''">
  49.     <xsl:value-of select="$override"/>
  50.       </xsl:when>
  51.       <xsl:otherwise>
  52.     <xsl:value-of select="$mark"/>
  53.       </xsl:otherwise>
  54.     </xsl:choose>
  55.   </xsl:variable>
  56.  
  57.   <xsl:variable name="cssmark">
  58.     <xsl:choose>
  59.       <xsl:when test="$usemark = 'bullet'">disc</xsl:when>
  60.       <xsl:when test="$usemark = 'box'">square</xsl:when>
  61.       <xsl:otherwise>
  62.     <xsl:value-of select="$usemark"/>
  63.       </xsl:otherwise>
  64.     </xsl:choose>
  65.   </xsl:variable>
  66.  
  67.   <li>
  68.     <xsl:if test="$css.decoration = '1' and $cssmark != ''">
  69.       <xsl:attribute name="style">
  70.     <xsl:text>list-style-type: </xsl:text>
  71.     <xsl:value-of select="$cssmark"/>
  72.       </xsl:attribute>
  73.     </xsl:if>
  74.  
  75.     <!-- we can't just drop the anchor in since some browsers (Opera)
  76.          get confused about line breaks if we do. So if the first child
  77.          is a para, assume the para will put in the anchor. Otherwise,
  78.          put the anchor in anyway. -->
  79.     <xsl:if test="local-name(child::*[1]) != 'para'">
  80.       <xsl:call-template name="anchor"/>
  81.     </xsl:if>
  82.  
  83.     <xsl:choose>
  84.       <xsl:when test="$show.revisionflag != 0 and @revisionflag">
  85.     <div class="{@revisionflag}">
  86.       <xsl:apply-templates/>
  87.     </div>
  88.       </xsl:when>
  89.       <xsl:otherwise>
  90.     <xsl:apply-templates/>
  91.       </xsl:otherwise>
  92.     </xsl:choose>
  93.   </li>
  94. </xsl:template>
  95.  
  96. <xsl:template name="orderedlist-starting-number">
  97.   <xsl:param name="list" select="."/>
  98.   <xsl:choose>
  99.     <xsl:when test="$list/@continuation != 'continues'">1</xsl:when>
  100.     <xsl:otherwise>
  101.       <xsl:variable name="prevlist"
  102.                     select="$list/preceding::orderedlist[1]"/>
  103.       <xsl:choose>
  104.         <xsl:when test="count($prevlist) = 0">2</xsl:when>
  105.         <xsl:otherwise>
  106.           <xsl:variable name="prevlength" select="count($prevlist/listitem)"/>
  107.           <xsl:variable name="prevstart">
  108.             <xsl:call-template name="orderedlist-starting-number">
  109.               <xsl:with-param name="list" select="$prevlist"/>
  110.             </xsl:call-template>
  111.           </xsl:variable>
  112.           <xsl:value-of select="$prevstart + $prevlength"/>
  113.         </xsl:otherwise>
  114.       </xsl:choose>
  115.     </xsl:otherwise>
  116.   </xsl:choose>
  117. </xsl:template>
  118.  
  119. <xsl:template match="orderedlist">
  120.   <xsl:variable name="start">
  121.     <xsl:choose>
  122.       <xsl:when test="@continuation='continues'">
  123.         <xsl:call-template name="orderedlist-starting-number"/>
  124.       </xsl:when>
  125.       <xsl:otherwise>1</xsl:otherwise>
  126.     </xsl:choose>
  127.   </xsl:variable>
  128.  
  129.   <xsl:variable name="numeration">
  130.     <xsl:call-template name="list.numeration"/>
  131.   </xsl:variable>
  132.  
  133.   <xsl:variable name="type">
  134.     <xsl:choose>
  135.       <xsl:when test="$numeration='arabic'">1</xsl:when>
  136.       <xsl:when test="$numeration='loweralpha'">a</xsl:when>
  137.       <xsl:when test="$numeration='lowerroman'">i</xsl:when>
  138.       <xsl:when test="$numeration='upperalpha'">A</xsl:when>
  139.       <xsl:when test="$numeration='upperroman'">I</xsl:when>
  140.       <!-- What!? This should never happen -->
  141.       <xsl:otherwise>
  142.         <xsl:message>
  143.           <xsl:text>Unexpected numeration: </xsl:text>
  144.           <xsl:value-of select="$numeration"/>
  145.         </xsl:message>
  146.         <xsl:value-of select="1"/>
  147.       </xsl:otherwise>
  148.     </xsl:choose>
  149.   </xsl:variable>
  150.  
  151.   <div class="{name(.)}">
  152.     <xsl:call-template name="anchor"/>
  153.     <xsl:if test="title">
  154.       <xsl:apply-templates select="title"/>
  155.     </xsl:if>
  156.     <ol>
  157.     <xsl:if test="$start != '1'">
  158.       <xsl:attribute name="start">
  159.         <xsl:value-of select="$start"/>
  160.       </xsl:attribute>
  161.     </xsl:if>
  162.     <xsl:if test="$numeration != ''">
  163.       <xsl:attribute name="type">
  164.     <xsl:value-of select="$type"/>
  165.       </xsl:attribute>
  166.     </xsl:if>
  167.     <xsl:if test="@spacing='compact'">
  168.       <xsl:attribute name="compact">
  169.     <xsl:value-of select="compact"/>
  170.       </xsl:attribute>
  171.     </xsl:if>
  172.     <xsl:apply-templates select="listitem"/>
  173.     </ol>
  174.   </div>
  175. </xsl:template>
  176.  
  177. <xsl:template match="orderedlist/title">
  178.   <p class="title"><b><xsl:apply-templates/></b></p>
  179. </xsl:template>
  180.  
  181. <xsl:template match="orderedlist/listitem">
  182.   <li>
  183.     <xsl:if test="@override">
  184.       <xsl:attribute name="value">
  185.         <xsl:value-of select="@override"/>
  186.       </xsl:attribute>
  187.     </xsl:if>
  188.  
  189.     <!-- we can't just drop the anchor in since some browsers (Opera)
  190.          get confused about line breaks if we do. So if the first child
  191.          is a para, assume the para will put in the anchor. Otherwise,
  192.          put the anchor in anyway. -->
  193.     <xsl:if test="local-name(child::*[1]) != 'para'">
  194.       <xsl:call-template name="anchor"/>
  195.     </xsl:if>
  196.  
  197.     <xsl:choose>
  198.       <xsl:when test="$show.revisionflag != 0 and @revisionflag">
  199.     <div class="{@revisionflag}">
  200.       <xsl:apply-templates/>
  201.     </div>
  202.       </xsl:when>
  203.       <xsl:otherwise>
  204.     <xsl:apply-templates/>
  205.       </xsl:otherwise>
  206.     </xsl:choose>
  207.   </li>
  208. </xsl:template>
  209.  
  210. <xsl:template match="variablelist">
  211.   <xsl:variable name="pi-presentation">
  212.     <xsl:call-template name="dbhtml-attribute">
  213.       <xsl:with-param name="pis"
  214.                       select="processing-instruction('dbhtml')"/>
  215.       <xsl:with-param name="attribute" select="'list-presentation'"/>
  216.     </xsl:call-template>
  217.   </xsl:variable>
  218.  
  219.   <xsl:variable name="presentation">
  220.     <xsl:choose>
  221.       <xsl:when test="$pi-presentation != ''">
  222.         <xsl:value-of select="$pi-presentation"/>
  223.       </xsl:when>
  224.       <xsl:when test="$variablelist.as.table != 0">
  225.         <xsl:value-of select="'table'"/>
  226.       </xsl:when>
  227.       <xsl:otherwise>
  228.         <xsl:value-of select="'list'"/>
  229.       </xsl:otherwise>
  230.     </xsl:choose>
  231.   </xsl:variable>
  232.  
  233.   <xsl:variable name="list-width">
  234.     <xsl:call-template name="dbhtml-attribute">
  235.       <xsl:with-param name="pis"
  236.                       select="processing-instruction('dbhtml')"/>
  237.       <xsl:with-param name="attribute" select="'list-width'"/>
  238.     </xsl:call-template>
  239.   </xsl:variable>
  240.  
  241.   <xsl:variable name="term-width">
  242.     <xsl:call-template name="dbhtml-attribute">
  243.       <xsl:with-param name="pis"
  244.                       select="processing-instruction('dbhtml')"/>
  245.       <xsl:with-param name="attribute" select="'term-width'"/>
  246.     </xsl:call-template>
  247.   </xsl:variable>
  248.  
  249.   <xsl:variable name="table-summary">
  250.     <xsl:call-template name="dbhtml-attribute">
  251.       <xsl:with-param name="pis"
  252.                       select="processing-instruction('dbhtml')"/>
  253.       <xsl:with-param name="attribute" select="'table-summary'"/>
  254.     </xsl:call-template>
  255.   </xsl:variable>
  256.  
  257.   <div class="{name(.)}">
  258.     <xsl:call-template name="anchor"/>
  259.     <xsl:if test="title">
  260.       <xsl:apply-templates select="title"/>
  261.     </xsl:if>
  262.  
  263.     <xsl:choose>
  264.       <xsl:when test="$presentation = 'table'">
  265.         <table border="0">
  266.           <xsl:if test="$list-width != ''">
  267.             <xsl:attribute name="width">
  268.               <xsl:value-of select="$list-width"/>
  269.             </xsl:attribute>
  270.           </xsl:if>
  271.           <xsl:if test="$table-summary != ''">
  272.             <xsl:attribute name="summary">
  273.               <xsl:value-of select="$table-summary"/>
  274.             </xsl:attribute>
  275.           </xsl:if>
  276.           <col align="left">
  277.             <xsl:if test="$term-width != ''">
  278.               <xsl:attribute name="width">
  279.                 <xsl:value-of select="$term-width"/>
  280.               </xsl:attribute>
  281.             </xsl:if>
  282.           </col>
  283.           <tbody>
  284.             <xsl:apply-templates select="varlistentry" mode="varlist-table"/>
  285.           </tbody>
  286.         </table>
  287.       </xsl:when>
  288.       <xsl:otherwise>
  289.         <dl>
  290.           <xsl:apply-templates select="varlistentry"/>
  291.         </dl>
  292.       </xsl:otherwise>
  293.     </xsl:choose>
  294.   </div>
  295. </xsl:template>
  296.  
  297. <xsl:template match="variablelist/title">
  298.   <p class="title"><b><xsl:apply-templates/></b></p>
  299. </xsl:template>
  300.  
  301. <xsl:template match="listitem" mode="xref">
  302.   <xsl:number format="1"/>
  303. </xsl:template>
  304.  
  305. <xsl:template match="listitem/simpara" priority="2">
  306.   <!-- If a listitem contains only a single simpara, don't output
  307.        the <p> wrapper; this has the effect of creating an li
  308.        with simple text content. -->
  309.   <xsl:choose>
  310.     <xsl:when test="not(preceding-sibling::*)
  311.                     and not (following-sibling::*)">
  312.       <xsl:call-template name="anchor"/>
  313.       <xsl:apply-templates/>
  314.     </xsl:when>
  315.     <xsl:otherwise>
  316.       <p>
  317.         <xsl:call-template name="anchor"/>
  318.         <xsl:apply-templates/>
  319.       </p>
  320.     </xsl:otherwise>
  321.   </xsl:choose>
  322. </xsl:template>
  323.  
  324. <xsl:template match="varlistentry">
  325.   <dt>
  326.     <xsl:call-template name="anchor"/>
  327.     <xsl:apply-templates select="term"/>
  328.   </dt>
  329.   <dd>
  330.     <xsl:apply-templates select="listitem"/>
  331.   </dd>
  332. </xsl:template>
  333.  
  334. <xsl:template match="varlistentry" mode="varlist-table">
  335.   <xsl:variable name="presentation">
  336.     <xsl:call-template name="dbhtml-attribute">
  337.       <xsl:with-param name="pis"
  338.                       select="../processing-instruction('dbhtml')"/>
  339.       <xsl:with-param name="attribute" select="'term-presentation'"/>
  340.     </xsl:call-template>
  341.   </xsl:variable>
  342.  
  343.   <xsl:variable name="separator">
  344.     <xsl:call-template name="dbhtml-attribute">
  345.       <xsl:with-param name="pis"
  346.                       select="../processing-instruction('dbhtml')"/>
  347.       <xsl:with-param name="attribute" select="'term-separator'"/>
  348.     </xsl:call-template>
  349.   </xsl:variable>
  350.   <tr>
  351.     <td>
  352.       <xsl:call-template name="anchor"/>
  353.       <xsl:choose>
  354.         <xsl:when test="$presentation = 'bold'">
  355.           <b>
  356.             <xsl:apply-templates select="term"/>
  357.             <xsl:value-of select="$separator"/>
  358.           </b>
  359.         </xsl:when>
  360.         <xsl:when test="$presentation = 'italic'">
  361.           <i>
  362.             <xsl:apply-templates select="term"/>
  363.             <xsl:value-of select="$separator"/>
  364.           </i>
  365.         </xsl:when>
  366.         <xsl:when test="$presentation = 'bold-italic'">
  367.           <b>
  368.             <i>
  369.               <xsl:apply-templates select="term"/>
  370.               <xsl:value-of select="$separator"/>
  371.             </i>
  372.           </b>
  373.         </xsl:when>
  374.         <xsl:otherwise>
  375.           <xsl:apply-templates select="term"/>
  376.           <xsl:value-of select="$separator"/>
  377.         </xsl:otherwise>
  378.       </xsl:choose>
  379.     </td>
  380.     <td>
  381.       <xsl:apply-templates select="listitem"/>
  382.     </td>
  383.   </tr>
  384. </xsl:template>
  385.  
  386. <xsl:template match="varlistentry/term">
  387.   <span class="term">
  388.     <xsl:call-template name="anchor"/>
  389.     <xsl:apply-templates/>
  390.     <xsl:text>, </xsl:text>
  391.   </span>
  392. </xsl:template>
  393.  
  394. <xsl:template match="varlistentry/term[position()=last()]" priority="2">
  395.   <span class="term">
  396.     <xsl:call-template name="anchor"/>
  397.     <xsl:apply-templates/>
  398.   </span>
  399. </xsl:template>
  400.  
  401. <xsl:template match="varlistentry/listitem">
  402.   <xsl:choose>
  403.     <xsl:when test="$show.revisionflag != 0 and @revisionflag">
  404.       <div class="{@revisionflag}">
  405.     <xsl:apply-templates/>
  406.       </div>
  407.     </xsl:when>
  408.     <xsl:otherwise>
  409.       <xsl:apply-templates/>
  410.     </xsl:otherwise>
  411.   </xsl:choose>
  412. </xsl:template>
  413.  
  414. <!-- ==================================================================== -->
  415.  
  416. <xsl:template match="simplelist">
  417.   <!-- with no type specified, the default is 'vert' -->
  418.   <xsl:call-template name="anchor"/>
  419.   <table class="simplelist" border="0" summary="Simple list">
  420.     <xsl:call-template name="simplelist.vert">
  421.       <xsl:with-param name="cols">
  422.     <xsl:choose>
  423.       <xsl:when test="@columns">
  424.         <xsl:value-of select="@columns"/>
  425.       </xsl:when>
  426.       <xsl:otherwise>1</xsl:otherwise>
  427.     </xsl:choose>
  428.       </xsl:with-param>
  429.     </xsl:call-template>
  430.   </table>
  431. </xsl:template>
  432.  
  433. <xsl:template match="simplelist[@type='inline']">
  434.   <span class="{name(.)}">
  435.     <xsl:call-template name="anchor"/>
  436.     <xsl:apply-templates/>
  437.   </span>
  438. </xsl:template>
  439.  
  440. <xsl:template match="simplelist[@type='horiz']">
  441.   <xsl:call-template name="anchor"/>
  442.   <table class="simplelist" border="0" summary="Simple list">
  443.     <xsl:call-template name="simplelist.horiz">
  444.       <xsl:with-param name="cols">
  445.         <xsl:choose>
  446.           <xsl:when test="@columns">
  447.             <xsl:value-of select="@columns"/>
  448.           </xsl:when>
  449.           <xsl:otherwise>1</xsl:otherwise>
  450.         </xsl:choose>
  451.       </xsl:with-param>
  452.     </xsl:call-template>
  453.   </table>
  454. </xsl:template>
  455.  
  456. <xsl:template match="simplelist[@type='vert']">
  457.   <xsl:call-template name="anchor"/>
  458.   <table class="simplelist" border="0" summary="Simple list">
  459.     <xsl:call-template name="simplelist.vert">
  460.       <xsl:with-param name="cols">
  461.         <xsl:choose>
  462.           <xsl:when test="@columns">
  463.             <xsl:value-of select="@columns"/>
  464.           </xsl:when>
  465.           <xsl:otherwise>1</xsl:otherwise>
  466.         </xsl:choose>
  467.       </xsl:with-param>
  468.     </xsl:call-template>
  469.   </table>
  470. </xsl:template>
  471.  
  472. <xsl:template name="simplelist.horiz">
  473.   <xsl:param name="cols">1</xsl:param>
  474.   <xsl:param name="cell">1</xsl:param>
  475.   <xsl:param name="members" select="./member"/>
  476.  
  477.   <xsl:if test="$cell <= count($members)">
  478.     <tr>
  479.       <xsl:call-template name="simplelist.horiz.row">
  480.         <xsl:with-param name="cols" select="$cols"/>
  481.         <xsl:with-param name="cell" select="$cell"/>
  482.         <xsl:with-param name="members" select="$members"/>
  483.       </xsl:call-template>
  484.    </tr>
  485.     <xsl:call-template name="simplelist.horiz">
  486.       <xsl:with-param name="cols" select="$cols"/>
  487.       <xsl:with-param name="cell" select="$cell + $cols"/>
  488.       <xsl:with-param name="members" select="$members"/>
  489.     </xsl:call-template>
  490.   </xsl:if>
  491. </xsl:template>
  492.  
  493. <xsl:template name="simplelist.horiz.row">
  494.   <xsl:param name="cols">1</xsl:param>
  495.   <xsl:param name="cell">1</xsl:param>
  496.   <xsl:param name="members" select="./member"/>
  497.   <xsl:param name="curcol">1</xsl:param>
  498.  
  499.   <xsl:if test="$curcol <= $cols">
  500.     <td>
  501.       <xsl:choose>
  502.         <xsl:when test="$members[position()=$cell]">
  503.           <xsl:apply-templates select="$members[position()=$cell]"/>
  504.         </xsl:when>
  505.         <xsl:otherwise>
  506.           <xsl:choose>
  507.             <xsl:when test="$using.chunker != 0">
  508.               <xsl:text> </xsl:text>
  509.             </xsl:when>
  510.             <xsl:otherwise>
  511.               <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
  512.             </xsl:otherwise>
  513.           </xsl:choose>
  514.         </xsl:otherwise>
  515.       </xsl:choose>
  516.     </td>
  517.     <xsl:call-template name="simplelist.horiz.row">
  518.       <xsl:with-param name="cols" select="$cols"/>
  519.       <xsl:with-param name="cell" select="$cell+1"/>
  520.       <xsl:with-param name="members" select="$members"/>
  521.       <xsl:with-param name="curcol" select="$curcol+1"/>
  522.     </xsl:call-template>
  523.   </xsl:if>
  524. </xsl:template>
  525.  
  526. <xsl:template name="simplelist.vert">
  527.   <xsl:param name="cols">1</xsl:param>
  528.   <xsl:param name="cell">1</xsl:param>
  529.   <xsl:param name="members" select="./member"/>
  530.   <xsl:param name="rows"
  531.              select="floor((count($members)+$cols - 1) div $cols)"/>
  532.  
  533.   <xsl:if test="$cell <= $rows">
  534.     <tr>
  535.       <xsl:call-template name="simplelist.vert.row">
  536.     <xsl:with-param name="cols" select="$cols"/>
  537.     <xsl:with-param name="rows" select="$rows"/>
  538.     <xsl:with-param name="cell" select="$cell"/>
  539.     <xsl:with-param name="members" select="$members"/>
  540.       </xsl:call-template>
  541.     </tr>
  542.     <xsl:call-template name="simplelist.vert">
  543.       <xsl:with-param name="cols" select="$cols"/>
  544.       <xsl:with-param name="cell" select="$cell+1"/>
  545.       <xsl:with-param name="members" select="$members"/>
  546.       <xsl:with-param name="rows" select="$rows"/>
  547.     </xsl:call-template>
  548.   </xsl:if>
  549. </xsl:template>
  550.  
  551. <xsl:template name="simplelist.vert.row">
  552.   <xsl:param name="cols">1</xsl:param>
  553.   <xsl:param name="rows">1</xsl:param>
  554.   <xsl:param name="cell">1</xsl:param>
  555.   <xsl:param name="members" select="./member"/>
  556.   <xsl:param name="curcol">1</xsl:param>
  557.  
  558.   <xsl:if test="$curcol <= $cols">
  559.     <td>
  560.       <xsl:choose>
  561.         <xsl:when test="$members[position()=$cell]">
  562.           <xsl:apply-templates select="$members[position()=$cell]"/>
  563.         </xsl:when>
  564.         <xsl:otherwise>
  565.           <xsl:choose>
  566.             <xsl:when test="$using.chunker != 0">
  567.               <xsl:text> </xsl:text>
  568.             </xsl:when>
  569.             <xsl:otherwise>
  570.               <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
  571.             </xsl:otherwise>
  572.           </xsl:choose>
  573.         </xsl:otherwise>
  574.       </xsl:choose>
  575.     </td>
  576.     <xsl:call-template name="simplelist.vert.row">
  577.       <xsl:with-param name="cols" select="$cols"/>
  578.       <xsl:with-param name="rows" select="$rows"/>
  579.       <xsl:with-param name="cell" select="$cell+$rows"/>
  580.       <xsl:with-param name="members" select="$members"/>
  581.       <xsl:with-param name="curcol" select="$curcol+1"/>
  582.     </xsl:call-template>
  583.   </xsl:if>
  584. </xsl:template>
  585.  
  586. <xsl:template match="member">
  587.   <xsl:apply-templates/>
  588. </xsl:template>
  589.  
  590. <xsl:template match="simplelist[@type='inline']/member">
  591.   <xsl:apply-templates/>
  592.   <xsl:text>, </xsl:text>
  593. </xsl:template>
  594.  
  595. <xsl:template match="simplelist[@type='inline']/member[position()=last()]"
  596.               priority="2">
  597.   <xsl:apply-templates/>
  598. </xsl:template>
  599.  
  600. <!-- ==================================================================== -->
  601.  
  602. <xsl:template match="procedure">
  603.   <xsl:variable name="param.placement"
  604.                 select="substring-after(normalize-space($formal.title.placement),
  605.                                         concat(local-name(.), ' '))"/>
  606.  
  607.   <xsl:variable name="placement">
  608.     <xsl:choose>
  609.       <xsl:when test="contains($param.placement, ' ')">
  610.         <xsl:value-of select="substring-before($param.placement, ' ')"/>
  611.       </xsl:when>
  612.       <xsl:when test="$param.placement = ''">before</xsl:when>
  613.       <xsl:otherwise>
  614.         <xsl:value-of select="$param.placement"/>
  615.       </xsl:otherwise>
  616.     </xsl:choose>
  617.   </xsl:variable>
  618.  
  619.   <xsl:variable name="preamble"
  620.                 select="*[not(self::step or self::title)]"/>
  621.  
  622.   <div class="{name(.)}">
  623.     <xsl:call-template name="anchor"/>
  624.  
  625.     <xsl:if test="title and $placement = 'before'">
  626.       <xsl:choose>
  627.         <xsl:when test="$formal.procedures != 0">
  628.           <xsl:call-template name="formal.object.heading"/>
  629.         </xsl:when>
  630.         <xsl:otherwise>
  631.           <xsl:apply-templates select="title"/>
  632.         </xsl:otherwise>
  633.       </xsl:choose>
  634.     </xsl:if>
  635.  
  636.     <xsl:apply-templates select="$preamble"/>
  637.  
  638.     <xsl:choose>
  639.       <xsl:when test="count(step) = 1">
  640.         <ul>
  641.           <xsl:apply-templates select="step"/>
  642.         </ul>
  643.       </xsl:when>
  644.       <xsl:otherwise>
  645.         <ol>
  646.           <xsl:attribute name="type">
  647.             <xsl:value-of select="substring($procedure.step.numeration.formats,1,1)"/>
  648.           </xsl:attribute>
  649.           <xsl:apply-templates select="step"/>
  650.         </ol>
  651.       </xsl:otherwise>
  652.     </xsl:choose>
  653.  
  654.     <xsl:if test="title and $placement != 'before'">
  655.       <xsl:choose>
  656.         <xsl:when test="$formal.procedures != 0">
  657.           <xsl:call-template name="formal.object.heading"/>
  658.         </xsl:when>
  659.         <xsl:otherwise>
  660.           <xsl:apply-templates select="title"/>
  661.         </xsl:otherwise>
  662.       </xsl:choose>
  663.     </xsl:if>
  664.   </div>
  665. </xsl:template>
  666.  
  667. <xsl:template match="procedure/title">
  668.   <p class="title">
  669.     <b>
  670.       <xsl:apply-templates/>
  671.     </b>
  672.   </p>
  673. </xsl:template>
  674.  
  675. <xsl:template match="title" mode="procedure.title.mode">
  676.   <p class="title">
  677.     <b>
  678.       <xsl:apply-templates/>
  679.     </b>
  680.   </p>
  681. </xsl:template>
  682.  
  683. <xsl:template match="substeps">
  684.   <xsl:variable name="numeration">
  685.     <xsl:call-template name="procedure.step.numeration"/>
  686.   </xsl:variable>
  687.  
  688.   <xsl:call-template name="anchor"/>
  689.  
  690.   <ol type="{$numeration}">
  691.     <xsl:apply-templates/>
  692.   </ol>
  693. </xsl:template>
  694.  
  695. <xsl:template match="step">
  696.   <li>
  697.     <xsl:call-template name="anchor"/>
  698.     <xsl:apply-templates/>
  699.   </li>
  700. </xsl:template>
  701.  
  702. <xsl:template match="step/title">
  703.   <xsl:apply-templates select="." mode="procedure.title.mode"/>
  704. </xsl:template>
  705.  
  706. <!-- ==================================================================== -->
  707.  
  708. <xsl:template match="segmentedlist">
  709.   <xsl:variable name="presentation">
  710.     <xsl:call-template name="dbhtml-attribute">
  711.       <xsl:with-param name="pis"
  712.                       select="processing-instruction('dbhtml')"/>
  713.       <xsl:with-param name="attribute" select="'list-presentation'"/>
  714.     </xsl:call-template>
  715.   </xsl:variable>
  716.  
  717.   <div class="{name(.)}">
  718.     <xsl:call-template name="anchor"/>
  719.  
  720.     <xsl:choose>
  721.       <xsl:when test="$presentation = 'table'">
  722.         <xsl:apply-templates select="." mode="seglist-table"/>
  723.       </xsl:when>
  724.       <xsl:when test="$presentation = 'list'">
  725.         <xsl:apply-templates/>
  726.       </xsl:when>
  727.       <xsl:when test="$segmentedlist.as.table != 0">
  728.         <xsl:apply-templates select="." mode="seglist-table"/>
  729.       </xsl:when>
  730.       <xsl:otherwise>
  731.         <xsl:apply-templates/>
  732.       </xsl:otherwise>
  733.     </xsl:choose>
  734.   </div>
  735. </xsl:template>
  736.  
  737. <xsl:template match="segmentedlist/title">
  738.   <p><b><xsl:apply-templates/></b></p>
  739. </xsl:template>
  740.  
  741. <xsl:template match="segtitle">
  742. </xsl:template>
  743.  
  744. <xsl:template match="segtitle" mode="segtitle-in-seg">
  745.   <xsl:apply-templates/>
  746. </xsl:template>
  747.  
  748. <xsl:template match="seglistitem">
  749.   <xsl:apply-templates/>
  750. </xsl:template>
  751.  
  752. <xsl:template match="seg">
  753.   <xsl:variable name="segnum" select="position()"/>
  754.   <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  755.   <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  756.  
  757.   <!--
  758.      Note: segtitle is only going to be the right thing in a well formed
  759.      SegmentedList.  If there are too many Segs or too few SegTitles,
  760.      you'll get something odd...maybe an error
  761.   -->
  762.  
  763.   <p>
  764.     <b>
  765.       <xsl:apply-templates select="$segtitles[$segnum=position()]"
  766.                            mode="segtitle-in-seg"/>
  767.       <xsl:text>: </xsl:text>
  768.     </b>
  769.     <xsl:apply-templates/>
  770.   </p>
  771. </xsl:template>
  772.  
  773. <xsl:template match="segmentedlist" mode="seglist-table">
  774.   <xsl:variable name="table-summary">
  775.     <xsl:call-template name="dbhtml-attribute">
  776.       <xsl:with-param name="pis"
  777.                       select="processing-instruction('dbhtml')"/>
  778.       <xsl:with-param name="attribute" select="'table-summary'"/>
  779.     </xsl:call-template>
  780.   </xsl:variable>
  781.  
  782.   <xsl:variable name="list-width">
  783.     <xsl:call-template name="dbhtml-attribute">
  784.       <xsl:with-param name="pis"
  785.                       select="processing-instruction('dbhtml')"/>
  786.       <xsl:with-param name="attribute" select="'list-width'"/>
  787.     </xsl:call-template>
  788.   </xsl:variable>
  789.  
  790.   <xsl:apply-templates select="title"/>
  791.  
  792.   <table border="0">
  793.     <xsl:if test="$list-width != ''">
  794.       <xsl:attribute name="width">
  795.         <xsl:value-of select="$list-width"/>
  796.       </xsl:attribute>
  797.     </xsl:if>
  798.     <xsl:if test="$table-summary != ''">
  799.       <xsl:attribute name="summary">
  800.         <xsl:value-of select="$table-summary"/>
  801.       </xsl:attribute>
  802.     </xsl:if>
  803.     <thead>
  804.       <tr>
  805.         <xsl:apply-templates select="segtitle" mode="seglist-table"/>
  806.       </tr>
  807.     </thead>
  808.     <tbody>
  809.       <xsl:apply-templates select="seglistitem" mode="seglist-table"/>
  810.     </tbody>
  811.   </table>
  812. </xsl:template>
  813.  
  814. <xsl:template match="segtitle" mode="seglist-table">
  815.   <th><xsl:apply-templates/></th>
  816. </xsl:template>
  817.  
  818. <xsl:template match="seglistitem" mode="seglist-table">
  819.   <tr>
  820.     <xsl:apply-templates mode="seglist-table"/>
  821.   </tr>
  822. </xsl:template>
  823.  
  824. <xsl:template match="seg" mode="seglist-table">
  825.   <td><xsl:apply-templates/></td>
  826. </xsl:template>
  827.  
  828. <!-- ==================================================================== -->
  829.  
  830. <xsl:template match="calloutlist">
  831.   <div class="{name(.)}">
  832.     <xsl:call-template name="anchor"/>
  833.     <xsl:if test="./title">
  834.       <p>
  835.         <b>
  836.           <xsl:apply-templates select="./title" mode="calloutlist.title.mode"/>
  837.         </b>
  838.       </p>
  839.     </xsl:if>
  840.     <xsl:choose>
  841.       <xsl:when test="$callout.list.table != 0">
  842.         <table border="0" summary="Callout list">
  843.           <xsl:apply-templates/>
  844.         </table>
  845.       </xsl:when>
  846.       <xsl:otherwise>
  847.         <dl compact="compact"><xsl:apply-templates/></dl>
  848.       </xsl:otherwise>
  849.     </xsl:choose>
  850.   </div>
  851. </xsl:template>
  852.  
  853. <xsl:template match="calloutlist/title">
  854. </xsl:template>
  855.  
  856. <xsl:template match="calloutlist/title" mode="calloutlist.title.mode">
  857.   <xsl:apply-templates/>
  858. </xsl:template>
  859.  
  860. <xsl:template match="callout">
  861.   <xsl:choose>
  862.     <xsl:when test="$callout.list.table != 0">
  863.       <tr>
  864.         <td width="5%" valign="top" align="left">
  865.           <xsl:call-template name="anchor"/>
  866.           <xsl:call-template name="callout.arearefs">
  867.             <xsl:with-param name="arearefs" select="@arearefs"/>
  868.           </xsl:call-template>
  869.         </td>
  870.         <td valign="top" align="left">
  871.           <xsl:apply-templates/>
  872.         </td>
  873.       </tr>
  874.     </xsl:when>
  875.     <xsl:otherwise>
  876.       <dt>
  877.         <xsl:call-template name="anchor"/>
  878.         <xsl:call-template name="callout.arearefs">
  879.           <xsl:with-param name="arearefs" select="@arearefs"/>
  880.         </xsl:call-template>
  881.       </dt>
  882.       <dd><xsl:apply-templates/></dd>
  883.     </xsl:otherwise>
  884.   </xsl:choose>
  885. </xsl:template>
  886.  
  887. <xsl:template name="callout.arearefs">
  888.   <xsl:param name="arearefs"></xsl:param>
  889.   <xsl:if test="$arearefs!=''">
  890.     <xsl:choose>
  891.       <xsl:when test="substring-before($arearefs,' ')=''">
  892.         <xsl:call-template name="callout.arearef">
  893.           <xsl:with-param name="arearef" select="$arearefs"/>
  894.         </xsl:call-template>
  895.       </xsl:when>
  896.       <xsl:otherwise>
  897.         <xsl:call-template name="callout.arearef">
  898.           <xsl:with-param name="arearef"
  899.                           select="substring-before($arearefs,' ')"/>
  900.         </xsl:call-template>
  901.       </xsl:otherwise>
  902.     </xsl:choose>
  903.     <xsl:call-template name="callout.arearefs">
  904.       <xsl:with-param name="arearefs"
  905.                       select="substring-after($arearefs,' ')"/>
  906.     </xsl:call-template>
  907.   </xsl:if>
  908. </xsl:template>
  909.  
  910. <xsl:template name="callout.arearef">
  911.   <xsl:param name="arearef"></xsl:param>
  912.   <xsl:variable name="targets" select="key('id',$arearef)"/>
  913.   <xsl:variable name="target" select="$targets[1]"/>
  914.  
  915.   <xsl:call-template name="check.id.unique">
  916.     <xsl:with-param name="linkend" select="$arearef"/>
  917.   </xsl:call-template>
  918.  
  919.   <xsl:choose>
  920.     <xsl:when test="count($target)=0">
  921.       <xsl:text>???</xsl:text>
  922.     </xsl:when>
  923.     <xsl:when test="local-name($target)='co'">
  924.       <a>
  925.         <xsl:attribute name="href">
  926.           <xsl:text>#</xsl:text>
  927.           <xsl:value-of select="$arearef"/>
  928.         </xsl:attribute>
  929.         <xsl:apply-templates select="$target" mode="callout-bug"/>
  930.       </a>
  931.       <xsl:text> </xsl:text>
  932.     </xsl:when>
  933.     <xsl:when test="local-name($target)='areaset'">
  934.       <xsl:call-template name="callout-bug">
  935.         <xsl:with-param name="conum">
  936.           <xsl:apply-templates select="$target" mode="conumber"/>
  937.         </xsl:with-param>
  938.       </xsl:call-template>
  939.     </xsl:when>
  940.     <xsl:when test="local-name($target)='area'">
  941.       <xsl:choose>
  942.         <xsl:when test="$target/parent::areaset">
  943.           <xsl:call-template name="callout-bug">
  944.             <xsl:with-param name="conum">
  945.               <xsl:apply-templates select="$target/parent::areaset"
  946.                                    mode="conumber"/>
  947.             </xsl:with-param>
  948.           </xsl:call-template>
  949.         </xsl:when>
  950.         <xsl:otherwise>
  951.           <xsl:call-template name="callout-bug">
  952.             <xsl:with-param name="conum">
  953.               <xsl:apply-templates select="$target" mode="conumber"/>
  954.             </xsl:with-param>
  955.           </xsl:call-template>
  956.         </xsl:otherwise>
  957.       </xsl:choose>
  958.     </xsl:when>
  959.     <xsl:otherwise>
  960.       <xsl:text>???</xsl:text>
  961.     </xsl:otherwise>
  962.   </xsl:choose>
  963. </xsl:template>
  964.  
  965. <!-- ==================================================================== -->
  966.  
  967. </xsl:stylesheet>
  968.  
  969. This resource fork intentionally left blank   ˇˇ